<?php
/**
 * JE Career package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2012 - 2013 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');
jimport('joomla.filesystem.file');

class hostingrajacareerModelCategory extends JModel
{
	/**
	 * Constructor that retrieves the ID from the request
	 *
	 * @access	public
	 * @return	void
	 */
	function __construct()
	{
		parent::__construct();

		$array 						= JRequest::getVar('cid',  0, '', 'array');
		$this->setId((int)$array[0]);
	}

	function setId($id)
	{
		// Set id and wipe data
		$this->_id					= $id;
		$this->_data				= null;
	}

	function &getData()
	{
		$row 						=& $this->getTable();
		$row->load( $this->_id );
		return $row;
	}

	function getGlobalsettings()
	{
		$db 						=& JFactory::getDBO();
		$query 						= 'SELECT * FROM #__hostingraja_career_settings WHERE id= 1';
		$db->setQuery( $query );
		if (!$db->query())	{
			echo $db->getErrorMsg();
		}
		$rows  						= $db->loadObject();
		return $rows;
	}

	function getAllCareers()
	{
		$all_id		   				= '';
		$db 		   				= & JFactory::getDBO();
		$rows->id[]	   				= 0;
		$query 	   					= "SELECT id FROM #__hostingraja_career_category where state = '1' ";
		$db->setQuery( $query );
		if (!$db->query())	{
			echo $db->getErrorMsg();
		}
		$rows      					= $db->loadObjectList();
		$id[] 						= 0;
		for( $i=0; $i<count($rows); $i++ ) {
			$row 					= &$rows[$i];
			$id[] 					= $row->id;
		}
		for( $i=0; $i<count($id); $i++ ) {
			if ( $i == count($id) - 1 ) {
				$val 				= '';
			} else {
				$val 				= ',';
			}
			$all_id .= $id[$i].$val;
		}
		return $all_id;
	}
}
?>